package com.zatech.cgnci.project.controller;


import com.zatech.cgnci.project.service.CgnciExchangeRateService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.Arrays;
import java.util.List;
import java.util.stream.Collectors;

/**
 * <p>
 * 币种汇率表 前端控制器
 * </p>
 *
 * @author Generator
 * @since 2024-12-17
 */
@RestController
@RequestMapping("/api/exchange-rate")
@RequiredArgsConstructor
@Api(produces = "application/json", tags = "币种汇率api接口文档")
public class CgnciExchangeRateController {

    private final CgnciExchangeRateService exchangeRateService;

    @GetMapping("/deleteById")
    @ApiOperation(value = "删除")
    public void deleteById(@RequestParam(value = "rateId") Long rateId) {
        exchangeRateService.removeById(rateId);
    }

    @GetMapping("/deleteByIds")
    @ApiOperation(value = "批量删除")
    public void deleteByIds(@RequestParam(value = "rateIds") String rateIds) {
        List<Long> rateIdList = Arrays.stream(rateIds.split(",")).map(Long::valueOf).collect(Collectors.toList());
        exchangeRateService.removeByIds(rateIdList);
    }

}

